package com.lujianfei.productprice.ui.addProduct;

public class AddProductModel implements AddProductContract.Model {
    private ProductEntity productEntity;
    private long id;
    private long shopId;
    @Override
    public ProductEntity getData(long id, long shopId) {
        this.id = id;
        this.shopId = shopId;
        productEntity = ProductEntity.findById(ProductEntity.class, id);
        return productEntity;
    }

    @Override
    public void save(String productName, String productPrice) {
        if (null==productEntity){
            productEntity = new ProductEntity();
        }
        productEntity.setShopId(this.shopId);
        productEntity.setProductName(productName);
        productEntity.setPrice(Double.parseDouble(productPrice));
        productEntity.save();
    }
}
